package com.example.demo.dao;

import com.example.demo.entity.Person;
import com.example.demo.entity.User;
import com.example.demo.entity.View;
import org.hibernate.annotations.Parameter;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.persistence.NamedQueries;
import java.util.List;

public interface PersonRepository extends JpaRepository<Person, Long> {
    //@Query(value="select new com.example.demo.entity.View(p,u) from Person p,User u where p.community = u.community")
//   @Query(value="select View from Person p,User u where p.community = u.community")

    @Query(value="select  u from User u where u.card = :card ")
    public List<User> findViewu(@Param("card") Long card);

    @Query(value="select p from Person p where p.community = :community")
    public List<Person> findViewp(@Param("community") String community);
}
